import Vue from 'vue';
import Router from 'vue-router';

// import SearchPage from '../components/search/search.vue';
// import SingerPage from '../components/singer/singer.vue';
// import RecommendPage from '../components/recommend/recommend.vue';
// import RankPage from '../components/rank/rank.vue';
// import SingerDetailPage from '../components/singer-detail/singer-detail.vue';
// import DiscPage from '../components/disc/disc.vue';
// import ToplistPage from '../components/top-list/top-list.vue';
// import UserCenter from '../components/user-center/user-center.vue';

// 异步加载方案
const RecommendPage = (resolve) => {
  import('../components/recommend/recommend.vue').then(module => {
    resolve(module);
  });
};
const SearchPage = (resolve) => {
  import('../components/search/search.vue').then(module => {
    resolve(module);
  });
};
const SingerPage = (resolve) => {
  import('../components/singer/singer.vue').then(module => {
    resolve(module);
  });
};
const RankPage = (resolve) => {
  import('../components/rank/rank.vue').then(module => {
    resolve(module);
  });
};
const SingerDetailPage = (resolve) => {
  import('../components/singer-detail/singer-detail.vue').then(module => {
    resolve(module);
  });
};
const DiscPage = (resolve) => {
  import('../components/disc/disc.vue').then(module => {
    resolve(module);
  });
};
const ToplistPage = (resolve) => {
  import('../components/top-list/top-list.vue').then(module => {
    resolve(module);
  });
};
const UserCenter = (resolve) => {
  import('../components/user-center/user-center.vue').then(module => {
    resolve(module);
  });
};

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '',
      redirect: '/recommend'
    },
    {
      path: '/recommend',
      component: RecommendPage,
      children: [
        {
          path: ':id',
          component: DiscPage
        }
      ]
    },
    {
      path: '/singer',
      component: SingerPage,
      children: [
        {
          path: ':id',
          component: SingerDetailPage
        }
      ]
    },
    {
      path: '/rank',
      component: RankPage,
      children: [{
        path: ':id',
        component: ToplistPage
      }]
    },
    {
      path: '/search',
      component: SearchPage,
      children: [
        {
          path: ':id',
          component: SingerDetailPage
        }
      ]
    },
    {
      path: '/user',
      component: UserCenter
    }
  ]
});
